package com.wz.project.agv.quene.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.agv.quene.domain.AgvQuene;
import com.wz.project.agv.quene.service.IAgvQueneService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * AGV执行队列Controller
 * 
 * @author wz
 * @date 2023-12-13
 */
@Controller
@RequestMapping("/system/quene")
public class AgvQueneController extends BaseController
{
    private String prefix = "system/quene";

    @Autowired
    private IAgvQueneService agvQueneService;

    @RequiresPermissions("system:quene:view")
    @GetMapping()
    public String quene()
    {
        return prefix + "/quene";
    }

    /**
     * 查询AGV执行队列列表
     */
//    @RequiresPermissions("system:quene:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AgvQuene agvQuene)
    {
        startPage();
        List<AgvQuene> list = agvQueneService.selectAgvQueneList(agvQuene);
        return getDataTable(list);
    }

    /**
     * 导出AGV执行队列列表
     */
    @RequiresPermissions("system:quene:export")
    @Log(title = "AGV执行队列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AgvQuene agvQuene)
    {
        List<AgvQuene> list = agvQueneService.selectAgvQueneList(agvQuene);
        ExcelUtil<AgvQuene> util = new ExcelUtil<AgvQuene>(AgvQuene.class);
        return util.exportExcel(list, "quene");
    }

    /**
     * 新增AGV执行队列
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存AGV执行队列
     */
    @RequiresPermissions("system:quene:add")
    @Log(title = "AGV执行队列", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AgvQuene agvQuene)
    {
        return toAjax(agvQueneService.insertAgvQuene(agvQuene));
    }

    /**
     * 修改AGV执行队列
     */
    @GetMapping("/edit/{taskNo}")
    public String edit(@PathVariable("taskNo") Long taskNo, ModelMap mmap)
    {
        AgvQuene agvQuene = agvQueneService.selectAgvQueneById(taskNo);
        mmap.put("agvQuene", agvQuene);
        return prefix + "/edit";
    }

    /**
     * 修改保存AGV执行队列
     */
    @RequiresPermissions("system:quene:edit")
    @Log(title = "AGV执行队列", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AgvQuene agvQuene)
    {
        return toAjax(agvQueneService.updateAgvQuene(agvQuene));
    }

    /**
     * 删除AGV执行队列
     */
    @RequiresPermissions("system:quene:remove")
    @Log(title = "AGV执行队列", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(agvQueneService.deleteAgvQueneByIds(ids));
    }
}
